<template>
  <el-button @click="router.push({ name: 'Hello1' })">hello1</el-button>
  <el-button @click="router.push({ name: 'Hello2' })">hello2</el-button>
  <el-button @click="router.push({ name: 'Hello3' })">hello3</el-button>
  <el-row>
    <el-button
      @click="router.push({ name: 'Login', query: { [sourceRouterName]: encodeURIComponent(router.currentRoute.value.fullPath) } })"
    >
      登录页面
    </el-button>
    <el-button @click="getUserInfo">获取登录用户信息</el-button>
    <el-button @click="logout">登出</el-button>
    <el-button @click="test">测试</el-button>
  </el-row>
  <el-row>
    <el-button @click="getMenuForest">获取菜单森林</el-button>
  </el-row>
  <div>1</div>
  <div>1</div>
  <div>1</div>
  <div>1</div>
  <div>1</div>
  <div>1</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>1</div>
  <div>1</div>
  <div>1</div>
  <div>1</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>2</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
  <div>3</div>
</template>
<script setup lang="ts">
  import { AuthApi } from '/@/api/AuthApi.ts'
  import { SysMenuApi } from '/@/api/sysApi/SysMenuApi.ts'
  import { Menu } from '/@/module/Menu.ts'
  import { useRouter } from 'vue-router'
  import { Config } from '/@/config/Config.ts'

  const router = useRouter()

  const sourceRouterName = Config.router.sourceRouterName
  const getUserInfo = async () => {
    const { data } = await AuthApi.getLoginUser()
    console.log('登录用户信息', data)
  }

  const logout = async () => {
    const { data } = await AuthApi.logout()
    console.log('登出', data)
  }

  const getMenuForest = async () => {
    const { data } = await SysMenuApi.forest()

    console.log('菜单森林', data)
    const result = Menu.toRouter(data.data)
    console.log('解析后的菜单', result)
  }

  const test = () => {
    console.log(decodeURIComponent('/test?a=1&b=2&c=3'))
  }
</script>